package com.sykj.chengqiang.controller;

import com.sykj.bean.bis.BisShopPost;
import com.sykj.chengqiang.service.BisShopPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/bisShopPost")
public class BisShopPostController {


    @Autowired
    private BisShopPostService bisShopPostService;




    /**
     * 查询方法
     * @return
     */
    @RequestMapping("/queyrPost")
    public Object queyrPost(){
        List<BisShopPost> userList = bisShopPostService.list();

        return userList;
    }

    /**
     * 模糊查询
     * @return
     */
    @RequestMapping("/queyrPosts")
    public List<BisShopPost> queyrPosts(BisShopPost bisShopPost){


        return bisShopPostService.queyrPosts(bisShopPost);
    }


    /**
     * 添加
     * @param
     * @return
     */
    @RequestMapping("/savePost")
    public Object savePost(BisShopPost bisShopPost){

//        Map<String,Object> map=new HashMap<>();
//        try {
//
//            map.put("sta","Y");
//        }catch (Exception e){
//            map.put("sta","N");
//        }
        return bisShopPostService.save(bisShopPost);

    }

     /**
     * 删除
     */
    @RequestMapping("/deletePost")
    public Object deletePost(Integer postId){
        return bisShopPostService.removeById(postId);

    }


    /**
     * 根据id查询一行数据
     */
    @RequestMapping("/queyrByidPost")
    public Object queyrByidPost(Integer postId){
        BisShopPost post = bisShopPostService.getById(postId);
        return post;
    }


    /**
     * 修改
     */
    @RequestMapping("/updatePost")
    public Object updatePost(BisShopPost bisShopPost){
        boolean update = bisShopPostService.updateById(bisShopPost);
        return update;

    }


}
